package com.sy.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sy.dto.OrdersPageQueryDTO;
import com.sy.mapper.OrdersMapper;
import com.sy.pojo.Orders;
import com.sy.result.PageResult;
import com.sy.service.OrdersService;
import com.sy.vo.OrdersVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class OrdersServiceImpl
        extends ServiceImpl<OrdersMapper, Orders> implements OrdersService {

    @Autowired
    private OrdersMapper ordersMapper;

    /**
     * 订单分页查询
     * @param ordersPageQueryDTO
     * @return
     */
    @Override
    public PageResult findAll(OrdersPageQueryDTO ordersPageQueryDTO) {
        Page<OrdersVo> page = new Page<>(ordersPageQueryDTO.getPage(),
                ordersPageQueryDTO.getPageSize());
        page = ordersMapper.findAll(page, ordersPageQueryDTO.getName());
        return new PageResult(page.getTotal(), page.getRecords());
    }
}
